﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class QueueStrategy : IStrategy
{
    public QueueStrategy(Transform transform, float nearbyRadium, float forceWeight = 1) : base(transform, nearbyRadium, forceWeight) { }  

    public override Vector3 GetForce()
    {
        Vector3 tempDir = Vector3.zero;
        Vector3 alignmentForce = Vector3.zero;

        foreach (var item in this.mNearbyCrowList)
        {
            tempDir += item.transform.forward;
        }
        if (mNearbyCrowList.Count > 0)
        {
            tempDir /= mNearbyCrowList.Count;
            //获得最大的队列力
            alignmentForce = tempDir - this.mTransform.forward;
            alignmentForce *= mForceWeight;
        }

        return alignmentForce;
    }
}
